package com.uyaer.engine.display.el
{
	import com.uyaer.engine.text.TextCache;
	import com.uyaer.engine.utils.HashMap;
	import com.uyaer.engine.utils.Utils;
	
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.filters.GlowFilter;
	import flash.geom.Rectangle;
	
	public class DynamicSprite extends Sprite
	{
		public var bmAnim:Animation;
		
		/**
		 * 
		 * @param id  当前序列帧动画的名字  如： 1001_run
		 * @param totals  总共有多少帧，从0开始
		 * @param resBmd texture packer生成的BitmapData
		 * @param resName texture packer生成的描述 
		 * 
		 */		
		public function DynamicSprite(id:String , totals:int , bmd:BitmapData)
		{
			var framesClip:Vector.<Rectangle> = new Vector.<Rectangle>();
			for(var i :uint = 0 ; i < totals ; i ++){
				var key:String = id+"_"+Utils.complement(i,2)+".png";
				framesClip.push(TextCache.texturePacker.get(key) as Rectangle);
			}
			bmAnim = new Animation(id,bmd,framesClip);
			addChild(bmAnim);
		}
		
		public function render():void
		{
			if(!bmAnim.isShare){
				bmAnim.render();
			}
		}
		
		public function destory():void{
			if(!bmAnim.isShare){
//				bmAnim.destory();
			}
		}
	}
}